#include "window_setting.h"

#include "window_main.h"	
#include "window_manager.h"


static void event_handler(lv_event_t * e)
{
    lv_event_code_t code = lv_event_get_code(e);
    lv_obj_t * obj = lv_event_get_target(e);
    if(code == LV_EVENT_CLICKED) {  
        printf("Clicked: %s",__FUNCTION__);
			
        //printf("Clicked: %s", lv_list_get_btn_text(list1, obj));
    }
}
void window_setting_init()
{
   printf("%s\r\n",__FUNCTION__);
	#if 1
    lv_obj_t * list1=NULL;
		/*Create a list*/
    list1 = lv_list_create(lv_scr_act());

    lv_obj_set_size(list1, LV_HOR_RES_MAX, LV_VER_RES_MAX);
    lv_obj_center(list1);

	  lv_obj_set_style_bg_color(list1, lv_color_make(0,0,0), 0);//设置背景颜色为黑色


	  static lv_style_t lv_style;              //外部样式
    lv_style_init(&lv_style);           // 初始化按钮样式
	  lv_style_set_radius(&lv_style, 20); // 设置样式圆角弧度
	  //lv_obj_set_style_bg_color(list1, lv_color_make(0,0,0), 0);//设置背景颜色为黑色
	  lv_obj_set_scrollbar_mode(list1, LV_SCROLLBAR_MODE_OFF);  //取消滚动条显示
    //lv_obj_set_style_bg_opa(list1,LV_OPA_60,0);               //设置透明度
		lv_style_set_bg_color(&lv_style,lv_color_make(0,0,0));
	  lv_style_set_text_align(&lv_style,LV_TEXT_ALIGN_LEFT);
	  lv_style_set_pad_all(&lv_style,0); //铺满整个布局

	
    /*Add buttons to the list*/
		lv_obj_t * btn;
		btn = lv_list_add_btn(list1, (const char *)&zoom_BP_38, "Language");
		btn = lv_list_add_btn(list1, (const char *)&zoom_brightness_38, "Light");
		btn = lv_list_add_btn(list1, (const char *)&zoom_about_38, "About");
		btn = lv_list_add_btn(list1, (const char *)&zoom_sleep_38, "Factory");
		btn = lv_list_add_btn(list1, (const char *)&zoom_shutdown_38, "ShutDwon");
		btn = lv_list_add_btn(list1, (const char *)&zoom_sleep_38, "Restore");
		btn = lv_list_add_btn(list1, (const char *)&zoom_home_38, "Sound");
		btn = lv_list_add_btn(list1, (const char *)&zoom_find_phone_38, "Find Phone");

    lv_obj_add_style(list1, &lv_style, 0);

	uint32_t child_cnt = lv_obj_get_child_cnt(list1);  //获取当前的对象个数
	printf("child_cnt=%d\r\n",child_cnt);

	
//		for(int i=0; i<(child_cnt/2); i++)
//		{
//		     lv_obj_t * obj = lv_obj_get_child(list1,2*i); //获取指定索引的子对象
//			   lv_obj_t * obj1 = lv_obj_get_child(list1,2*i+1); //获取指定索引的子对象
//			   lv_coord_t x_pos  =	 lv_obj_get_x(obj); 
//			   lv_coord_t y_pos  =	 lv_obj_get_y(obj); 
//			
//				 lv_coord_t x_pos1  =	 lv_obj_get_x(obj1); 
//				 lv_obj_set_pos(obj,x_pos   + 50 ,y_pos);
//			   lv_obj_set_pos(obj1,x_pos1 + 150,y_pos);
//			
//			  printf("x_pos=%d,x_pos1=%d,y_pos=%d\r\n",x_pos,x_pos1,y_pos);
//		}


//    lv_list_add_text(list1, "File");
//    btn = lv_list_add_btn(list1, LV_SYMBOL_FILE, "New");
//    lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
////    btn = lv_list_add_btn(list1, LV_SYMBOL_DIRECTORY, "Open");
//    lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
////    btn = lv_list_add_btn(list1, LV_SYMBOL_SAVE, "Save");
//    lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
////    btn = lv_list_add_btn(list1, LV_SYMBOL_CLOSE, "Delete");
//    lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
////    btn = lv_list_add_btn(list1, LV_SYMBOL_EDIT, "Edit");
//    lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);

//    lv_list_add_text(list1, "Connectivity");
////    btn = lv_list_add_btn(list1, LV_SYMBOL_BLUETOOTH, "Bluetooth");
//    lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
////    btn = lv_list_add_btn(list1, LV_SYMBOL_GPS, "Navigation");
//    lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
////    btn = lv_list_add_btn(list1, LV_SYMBOL_USB, "USB");
//    lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
////    btn = lv_list_add_btn(list1, LV_SYMBOL_BATTERY_FULL, "Battery");
//    lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);

//    lv_list_add_text(list1, "Exit");
////    btn = lv_list_add_btn(list1, LV_SYMBOL_OK, "Apply");
//    lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
////    btn = lv_list_add_btn(list1, LV_SYMBOL_CLOSE, "Close");
//    lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
		#endif

}